package com.bj58.mis.bigdata.demo2.controller;


import com.bj58.bsp.v2.Provider;
import com.bj58.bsp.v2.exception.BspException;
import com.bj58.bsp.v2.utils.ServletLoginUtil;
import com.bj58.bsp.v2.user.vo.LoginUserBaseInfo;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {

    @RequestMapping("")
    public String index(){
        return "hello spring boot demo";
    }

    @RequestMapping("/whoami")
    public LoginUserBaseInfo whoami(HttpServletRequest request){
        LoginUserBaseInfo loginUserBaseInfo = ServletLoginUtil.getLoginUser(request);
        return loginUserBaseInfo;
    }


    @RequestMapping("/{module}/{model}")
    public String func(@PathVariable(name="module") String module, @PathVariable(name="model") String model){
        System.out.println(("[IndexController] [func]: module="+module+", model="+model));
        if("error".equals(model)){
            throw new RuntimeException("has a error");
        }
        return "aceess to [/"+module+"/"+model+"]";
    }

}
